const Sequelize = require('sequelize');
module.exports = function(sequelize, DataTypes) {
  return sequelize.define('act_ru_execution', {
    id: {
      type: DataTypes.STRING(64),
      allowNull: false,
      primaryKey: true,
      field: 'ID_'
    },
    rev: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'REV_'
    },
    procInstId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'PROC_INST_ID_'
    },
    businessKey: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'BUSINESS_KEY_'
    },
    parentId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'PARENT_ID_'
    },
    procDefId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_re_procdef',
        key: 'id_'
      },
      field: 'PROC_DEF_ID_'
    },
    superExec: {
      type: DataTypes.STRING(64),
      allowNull: true,
      references: {
        model: 'act_ru_execution',
        key: 'id_'
      },
      field: 'SUPER_EXEC_'
    },
    rootProcInstId: {
      type: DataTypes.STRING(64),
      allowNull: true,
      field: 'ROOT_PROC_INST_ID_'
    },
    actId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'ACT_ID_'
    },
    isActive: {
      type: DataTypes.TINYINT,
      allowNull: true,
      field: 'IS_ACTIVE_'
    },
    isConcurrent: {
      type: DataTypes.TINYINT,
      allowNull: true,
      field: 'IS_CONCURRENT_'
    },
    isScope: {
      type: DataTypes.TINYINT,
      allowNull: true,
      field: 'IS_SCOPE_'
    },
    isEventScope: {
      type: DataTypes.TINYINT,
      allowNull: true,
      field: 'IS_EVENT_SCOPE_'
    },
    isMiRoot: {
      type: DataTypes.TINYINT,
      allowNull: true,
      field: 'IS_MI_ROOT_'
    },
    suspensionState: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'SUSPENSION_STATE_'
    },
    cachedEntState: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'CACHED_ENT_STATE_'
    },
    tenantId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      defaultValue: "",
      field: 'TENANT_ID_'
    },
    name: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'NAME_'
    },
    startActId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'START_ACT_ID_'
    },
    startTime: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'START_TIME_'
    },
    startUserId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'START_USER_ID_'
    },
    lockTime: {
      type: DataTypes.DATE(3),
      allowNull: true,
      field: 'LOCK_TIME_'
    },
    isCountEnabled: {
      type: DataTypes.TINYINT,
      allowNull: true,
      field: 'IS_COUNT_ENABLED_'
    },
    evtSubscrCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'EVT_SUBSCR_COUNT_'
    },
    taskCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'TASK_COUNT_'
    },
    jobCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'JOB_COUNT_'
    },
    timerJobCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'TIMER_JOB_COUNT_'
    },
    suspJobCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'SUSP_JOB_COUNT_'
    },
    deadletterJobCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'DEADLETTER_JOB_COUNT_'
    },
    varCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'VAR_COUNT_'
    },
    idLinkCount: {
      type: DataTypes.INTEGER,
      allowNull: true,
      field: 'ID_LINK_COUNT_'
    },
    callbackId: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'CALLBACK_ID_'
    },
    callbackType: {
      type: DataTypes.STRING(255),
      allowNull: true,
      field: 'CALLBACK_TYPE_'
    }
  }, {
    sequelize,
    tableName: 'act_ru_execution',
    timestamps: false,
    indexes: [
      {
        name: "PRIMARY",
        unique: true,
        using: "BTREE",
        fields: [
          { name: "ID_" },
        ]
      },
      {
        name: "ACT_IDX_EXEC_BUSKEY",
        using: "BTREE",
        fields: [
          { name: "BUSINESS_KEY_" },
        ]
      },
      {
        name: "ACT_IDC_EXEC_ROOT",
        using: "BTREE",
        fields: [
          { name: "ROOT_PROC_INST_ID_" },
        ]
      },
      {
        name: "ACT_FK_EXE_PROCINST",
        using: "BTREE",
        fields: [
          { name: "PROC_INST_ID_" },
        ]
      },
      {
        name: "ACT_FK_EXE_PARENT",
        using: "BTREE",
        fields: [
          { name: "PARENT_ID_" },
        ]
      },
      {
        name: "ACT_FK_EXE_SUPER",
        using: "BTREE",
        fields: [
          { name: "SUPER_EXEC_" },
        ]
      },
      {
        name: "ACT_FK_EXE_PROCDEF",
        using: "BTREE",
        fields: [
          { name: "PROC_DEF_ID_" },
        ]
      },
    ]
  });
};
